import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_comm_base_framework/core/utils/ColorsUtil.dart';
import 'package:flutter_comm_base_framework/core/utils/string_utils.dart';

class CustomText extends StatelessWidget{
  String text;
  double textSize;
  Color textColor;
  Color bgColor;
  double width;
  EdgeInsets padding;
  EdgeInsets margin;
  FontWeight bold;
  TextStyle style;
  Alignment alignment;
  bool isEllipsis;
  final int maxLines;

  CustomText(this.text,{
      this.textSize = 14,
      this.textColor = ColorsUtil.black_333,
      this.bgColor = Colors.transparent,
      this.padding = const EdgeInsets.all(0),
      this.margin = const EdgeInsets.all(0),
      this.width,
      this.bold,
      this.style,
      this.alignment = Alignment.centerLeft,
      this.isEllipsis = true,
      this.maxLines
    }
  );

  @override
  Widget build(BuildContext context) {
    return Container(
      width: this.width,
      padding: this.padding,
      margin: this.margin,
      alignment: this.alignment,
      color: bgColor,
      child: Text(
        StringUtils.breakWord(StringUtils.isNull(this.text) ? "" : this.text),
        overflow: isEllipsis ? TextOverflow.ellipsis : TextOverflow.clip,
        maxLines: this.maxLines,
        style: style != null ? style : TextStyle(
          color: this.textColor,
          fontSize: this.textSize,
          fontWeight: this.bold,
        ),
      ),
    );
  }
}